<template>
  <el-cascader
      v-bind="fld"
      :value='value'
      :show-all-levels="fld.showAllLevels"
      :placeholder="fld.placeholder"
      :options="fld.options"
      :disabled="fld.disabled"
      :clearable="fld.clearable"
      :props="propsSelf"
      :filterable="fld.filterable"
      @change="handleChange"
      size="mini"
      ></el-cascader>
</template>
<script>
define(['vue'],function(vue){
  return vue.component('comp-cascader',{
    template: template,
    props : {
      fld :{required:false,default:function(){
        return {name:'',size:'mini'}
      }},
      value :{required:false,default:function(){
        // if(this.fld.props && this.fld.props.multiple) return [];
        return [];
      }},
    },
    data : function(){
      // if(this.fld.props && this.fld.props.multiple && !Array.isArray(this.value)) {
      //   console.error('comp-cascader组件为多选属性，value属性必须提供，且必须为数组，当前值为'+this.value,this.fld);
      // }
      var propsSelf = Object.assign({label:'text',value:'value'},this.fld.props||{});
      console.log({propsSelf},this.value);
      return {
        displayText:'',
        propsSelf:propsSelf
      };
    },
    mounted : function () {

    },
    methods:{
      handleModelInput :function(val){

      },
      handleChange : function(item) {
        // console.log({item});
        // this.$emit("change", item,this);
        this.$emit("input", item);
        var key = `${this.fld.name}:change`;
        if(!this.$root.callbacks[key]) return;
        this.$root.callbacks[key].apply(this,arguments);
      }
    }
  });
});

</script>
